// 中间内容大轮播图
var swiper = document.getElementById("swiper-image");
var pre = document.getElementById("goPre");
var next = document.getElementById("goNext");
var cicles = document.getElementById("cicle").getElementsByTagName("li");
var currentIndex = 0;//大轮播

function clearCheck() {
	for(var i=0;i<cicles.length;i++){
		cicles[i].className='cicle-item';
	}
}

function goIndex() {
	clearCheck();
	cicles[currentIndex].className='cicle-check cicle-item';
	swiper.setAttribute('src', "./image/swiper" + currentIndex + ".jpg");
}

pre.onclick = function() {
	currentIndex--;
	if (currentIndex < 0) {
		currentIndex = 4;
	}
	goIndex();
	// console.log("image/swiper" + currentIndex + ".jpg")
	
}
function goNext() {
	currentIndex++;
	if (currentIndex > 4) {
		currentIndex = 0;
	}
	goIndex();
	// console.log("image/swiper" + currentIndex + ".jpg")
}

//每2秒页面自动改变一次
setInterval(goNext, 5000);

document.getElementById("swiper-main").onmouseover = function() {
	pre.classList.remove("btn-hidden")
	next.classList.remove("btn-hidden")
};
document.getElementById("swiper-main").onmouseleave = function() {
	pre.classList.add("btn-hidden")
	next.classList.add("btn-hidden")
};
//圆圈点击跳转
for(var i=0;i<cicles.length;i++){
	cicles[i].addEventListener('click', function(){
		currentIndex = this.getAttribute('index');
		goIndex();
	})
}


//左侧小轮播
var pics = document.getElementById("s-pics").getElementsByTagName("li");
var picIndex=0;
function clearPicCheck() {
	for(var i=0;i<pics.length;i++){
		pics[i].className='';
	}
}

function goPicIndex() {
	clearPicCheck();
	pics[picIndex].className='pic-check';
	document.getElementById('sleft-box').style.background='url(./image/xyyx'+picIndex+'.jpg) no-repeat';
}
function goPicNext() {
	picIndex++;
	if (picIndex > 2) {
		picIndex = 0;
	}
	goPicIndex();
	// console.log("image/swiper" + currentIndex + ".jpg")
}
for(var i=0;i<pics.length;i++){
	pics[i].addEventListener('click', function(){
		picIndex = this.getAttribute('index');
		// console.log(picIndex);
		goPicIndex();
	})
}
setInterval(goPicNext, 5000);




